﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SM2TestRunner;

namespace Popups
{
    public partial class ThemeInputs : Form
    {
        public static string strAction;

        public ThemeInputs()
        {
            InitializeComponent();
        }

        public static DialogResult ShowThemeInputs(string action)
        {
            ThemeInputs dialog = new ThemeInputs();
            strAction = action;
            return dialog.ShowDialog();
        }

        private void ThemeInputs_Load(object sender, EventArgs e)
        {
            #region PROFILE
            cbbProfiles.DisplayMember = "Attribute2";
            cbbProfiles.ValueMember = "Attribute1";
            try
            {
                cbbProfiles.DataSource = Repository.ServerHardDataUtil.buildProfilesDataTable();
            }
            catch (Exception ex)
            {
                Utilities.GlobalObject.LOGGER.log("Failed to load ListBox Dashboard.CHART Utilities.GlobalInit.buildProfilesDataTable()");
                Utilities.GlobalObject.LOGGER.log(ex.ToString());
            }
            #endregion

            switch (strAction)
            {
                case "createThemeGraph":
                    #region
                    labelTitle.Text = "Create Theme Graph";
                    cbbProfiles.Enabled = true;radioButton3.Checked = true;
                    textBoxProfileName.Enabled = false;radioButton4.Checked = false;

                    radioButtonBasic.Checked = true;
                    radioButtonAdvance.Checked = false;
                    break;
                    #endregion

                default:
                    break;
            }
        }

        private void btnDISCARD_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            InputDispatcher.TEST_PARAMETER = new TestParameters();

            switch (strAction)
            {
                case "createThemeGraph":
                    #region

                    string strThemeGraphName = tbThemeGraphName.Text.Trim();
                    InputDispatcher.TEST_PARAMETER.add("Graph Name", strThemeGraphName);
                    
                    string strSelectedProfileName;
                    if (textBoxProfileName.Enabled)
                    {
                        strSelectedProfileName = textBoxProfileName.Text.Trim();
                        InputDispatcher.TEST_PARAMETER.add("Selected Profile", strSelectedProfileName);
                    }
                    else
                    {
                        strSelectedProfileName = cbbProfiles.SelectedValue.ToString();
                        InputDispatcher.TEST_PARAMETER.add("Selected Profile", strSelectedProfileName);
                    }

                    string strGraphType = "";
                    if (radioButtonBasic.Checked == true)
                        strGraphType = "Basic";
                    else strGraphType = "Advance";
                    InputDispatcher.TEST_PARAMETER.add("Graph Type", strGraphType);
                    break;
                    #endregion

                default:
                    break;
            }

            this.Close();
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            cbbProfiles.Enabled = false;
            textBoxProfileName.Enabled = true;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            cbbProfiles.Enabled = true;
            textBoxProfileName.Enabled = false;
        }
    }
}
